<?php
/**
 * PHP 5
 *
 * MIT License
 * Copyright (c) 2009 Christian Krause
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @category   library
 * @package    iLivGallery
 * @author     Original Author <ilivgallery@christiankrause.de>
 * @copyright  2009 Christian Krause
 * @license    MIT
 * @link       http://code.google.com/p/ilivgallery/downloads/
 * @since      File available since Release 0.5
 */

Class iLiv_Config {

	/**
	 * @var bool
	 */
	protected $thumbs_mirror	= true;
	/**
	 * @var bool
	 */
	protected $img_thumbs		= true;
	/**
	 * @var array
	 */
	protected $img_scale		= array(250, 640);
	/**
	 * @var string
	 */
	protected $gallery_name		= 'Setup Demo';
	/**
	 * @var string
	 */
	protected $gallery_path		= '../demo/';
	/**
	 * @var int
	 */
	protected $time_stamp		= 0;
	/**
	 * @var bool
	 */
	protected $use_doc_root		= false;

	/**
	 * @param string $key
	 * @param mixed $value
	 * @return bool
	 */
	public function __set($key, $value) {
		return $this->setValue($key, $value);
	}

	/**
	 * @param string $key
	 * @param mixed $value
	 * @return mixed
	 */
	public function __get($key) {
		return $this->getValue($key);
	}

	/**
	 * @param string $key
	 * @param mixed $value
	 * @return bool
	 */
	public function setValue($key, $value) {

		if ( $this->validateCfgKey($key) )
		{
			$this->$key = $value;
			return true;
		}

		return false;
	}

	/**
	 * @param string $key
	 * @return mixed
	 */
	public function getValue($key) {

		if ( $this->validateCfgKey($key) )
		{
			return $this->$key;
		}

		return null;
	}

	/**
	 * checks against decalared class members.
	 * @param $key
	 * @return bool
	 */
	protected function validateCfgKey($key) {

		if ( array_key_exists($key, get_class_vars(__CLASS__)) )
		{
			return true;
		}

		return false;
	}

}
